home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / arc / xadmaster.lha / xad / Developer / Include / Autodocs / xadsub.doc < prev   
Encoding:
Text File  |  2000-08-31  |  16.3 KB  |  360 lines

  1. TABLE OF CONTENTS
  2.  
  3. xadForeman/--Overview--
  4. xadClient/--Overview--
  5. xadClient/xcFree
  6. xadClient/xcGetInfo
  7. xadClient/xcRecogData
  8. xadClient/xcUnArchive
  9.  
  10. VERSION
  11.         $VER: xadsub.doc 8.0 (24.08.2000) by SDI
  12.  
  13. xadForeman/--Overview--                               xadForeman/--Overview--
  14.  
  15. The xadForeman structure is just some kind of header for external clients.
  16. It protects the clients from being executed accidentally by having a small
  17. piece of code (MOVEQ #-1,d0 : RTS) in the first 4 bytes.
  18. The master can identify a valid bunch of external clients by checking the
  19. first hunk of a file for the foreman identification.
  20. Finally, a foreman holds the pointer to a linked list of clients and thus
  21. enables the master to work with these clients.
  22. The version entry of this structure specifies name and version of the file
  23. and not of the linked client list!
  24.  
  25. Multiple clients can be stored in the linked list of one file. This allows
  26. to use code by different clients. E.g. The normal archive and a SFX client
  27. both use nearly equal unarchiving code, but different recognition functions.
  28.  
  29. If the clients have no double useable code, it is better to distribute them
  30. in seperate files to allow better updating.
  31.  
  32. xadClient/--Overview--                                 xadClient/--Overview--
  33.  
  34. The xadClient structure is the heart of the whole library system. Each
  35. client enables the master to recognize and unarchive files.
  36.  
  37. Therefore each client contains 4 routines that are called from the master.
  38. Pointers to these are stored in xc_RecogData, xc_GetInfo, xc_UnArchive and
  39. xc_Free.
  40.  
  41. All routines have one thing in common: the CPU registers D0/D1/A0/A1 are
  42. so-called scratch registers, they may change during execution, all other
  43. registers must remain unchanged. CPU register A6 holds a pointer to the
  44. xadMasterBase structure. See chapters below for a description of the client
  45. routines.
  46.  
  47. ALL CLIENT ROUTINES MUST BE REENTRANT! NEVER STORE ANY DATA IN STATIC
  48. MEMORY AREAS, USE THE STACK OR SOME ALLOCATED MEMORY INSTEAD! REMEMBER THAT
  49. THE ROUTINES MIGHT BE CALLED BY SEVERAL PROGRAMS AT THE SAME TIME! DO
  50. NOT EXCEED STACK USAGE (1KB SHOULD BE THE MAXIMUM), AS PROGRAMS NORMALLY
  51. HAVE ONLY 4KB STACK.
  52.  
  53. The name of the archiver that is supported by the client and the flags that
  54. describe the packer are stored in xc_ArchiverName and xc_Flags. Internal
  55. clients all have an unique ID value stored in xc_Identifier. If you have
  56. written a client that should replace an internal one, because it is faster
  57. or otherwise enhanced, simply put the ID of the client to be replaced in
  58. xc_Identifier. The old client will then be taken out of the list of used
  59. clients. Normally this ID should be zero. There is one problem with this:
  60. When the user deactivates external clients the xadmaster system is missing
  61. this type completely as internal client is not activated in this case.
  62.  
  63. xcRecogData() usually only requires a quite small part of a file to
  64. recognize it properly. To avoid reading the whole file for recognition
  65. purposes, you need to set xc_RecogSize to the minimum amount of bytes
  66. that is required to recognize the crunched file correctly.
  67. Note that xadmaster uses this value internally to decide whether a file
  68. might be archived with a archiver or not, so you don't have to do an extra
  69. size comparison in your xc_RecogData function any more.
  70. For archiver headers with non-constant sizes, simply set xc_RecogSize
  71. to a value that will ensure correct recognition of all possible files.
  72.  
  73. Whenever you intend to use features of the xadmaster.library in your
  74. clients that are marked (V2) or higher, make sure to set xc_MasterVersion
  75. to the desired version number, otherwise an old library version might
  76. crash while using the new client.
  77.  
  78. Whenever a client calls a xadmaster function and gets a return code, the
  79. client needs to return this code! So whenever an error code is produced
  80. somewhere, it must reach the calling program. This is most important
  81. for progress report (automatically called by xadHookAccess), as the
  82. XADERR_SKIP can be checked by calling program.
  83.  
  84. ANY needed structure must be allocated with xadAllocObject! None of the
  85. XAD structures can be allocated any other way!
  86.  
  87. Multivolume support:
  88. This system also supports multivolume archives. A special multivolume
  89. input stream (XAD_INSPLITTED) allows to pass multiple input files as
  90. one stream to the clients. This means multivolume archiver files are
  91. passed as ONE stream to the related client. The client may check the
  92. ai->xai_MultiVolume entry. This is an ULONG array witch holds the start
  93. offset of every part and is finished with an zero value. Note that the
  94. first entry is a zero value as well in normal case. The client may
  95. expect the parts to be in correct order, but must handle missing or
  96. defective parts (Handling of defective archives is necessary for normal
  97. archives as well!). Do not rely to much on part size information, as
  98. missing parts or defective parts normally will destroy the usefulness
  99. of that size information.
  100.  
  101. Filesystem clients:
  102. Starting with (V5), the library supports external filesystem clients as
  103. well. These clients have no xc_RecogData function, but get called xc_GetInfo
  104. always. The fields xc_RecogSize is useless as well for these clients.
  105. Filesystem clients are called, when xadGetDiskInfo() and xadDiskFileUnArc()
  106. are called. They are skipped for xadGetInfo(). The functions are equal
  107. to normal clients, except that they handle filesystem images and no
  108. file archives.
  109.  
  110. Apple Macintosh support:
  111. When handling special Apple archives, handle data and resource fork as
  112. separate entries into xadFileInfo list, with some additional information.
  113.  
  114. The flag XADFIF_MACDATA flag implies:
  115. - This file IS a data fork.
  116. - This file CAN have a separate resource fork.
  117. - This file's xfi_Comment (if not NULL) can be read as "TYPE/CRTR" or
  118.   "TYPE/CRTR FLGS", where TYPE and CRTR are 4 character ASCII codes
  119.   detailing a file's file ID and creator ID, and FLGS is a 4 digit
  120.   hexadecimal number detailing Finder Flags, as defined by the field
  121.   'FInfo.fdFlags' in RFC 1740.
  122. - The entry xfi_MacFork is either NULL or a pointer to the resource fork
  123.   list entry.
  124.  
  125. The flag XADFIF_MACRESOURCE flag implies:
  126. - This file IS a resource fork.
  127. - Suggested filename is "<datafork name>.rsrc".
  128. - This file DOES have a separate data fork.
  129. - The entry xfi_MacFork is a pointer to the data fork list entry.
  130. - If the data fork is empty, do not create an entry for it, but
  131.   leave xfi_MacFork empty and store the comment in resource fork entry.
  132.  
  133. NOTE: The pointer xfi_MacFork points to a normal entry of the file
  134. information list! This pointer is only additional information to find
  135. corresponding entries.
  136.  
  137. xadClient/xcFree                                             xadClient/xcFree
  138.  
  139.    NAME
  140.         xcFree -- Free all resources allocated by xcGetInfo
  141.  
  142.    SYNOPSIS
  143.         xcFree(ai, xadMasterBase)
  144.                A0       A6
  145.  
  146.         void xcFree(struct xadArchiveInfo *, struct xadMasterBase *)
  147.  
  148.    FUNCTION
  149.         This function frees all the stuff allocated by xcGetInfo. It is
  150.         called after unsuccessful xcGetInfo as well, so you need not to
  151.         call any freeing functions there. But be prepared for that case.
  152.         You must check all entries, as xcGetInfo may fail in the first
  153.         allocation stages (f.e. allocation of xadDiskInfo or xadFileInfo
  154.         structures).
  155.         Clear all entries you have freed! There should not be any pointers
  156.         left in xadArchiveInfo structure which do not point to valid
  157.         memory.
  158.  
  159.         Starting with (V2) the master library can do some stuff for you.
  160.         This is always done after calling this function, so you have the
  161.         chance to do private stuff before!
  162.         If you set the flag XADCF_FREEFILEINFO in xc_Flags, the master
  163.         library parses the xai_FileInfo list and frees every entry.
  164.         If you set the flag XADCF_FREEDISKINFO in xc_Flags, the master
  165.         library parses the xai_DiskInfo list and frees every entry.
  166.         If you set the flag XADCF_FREETEXTINFO in xc_Flags, the master
  167.         library parses the xdi_TextInfo list of every xadDiskInfo
  168.         structure and frees every entry.
  169.         If you set the flag XADCF_FREETEXTINFOTEXT in xc_Flags, the
  170.         master library frees xti_Text entry of xadTextInfo structures.
  171.         This requires these entries to be allocated with xadAllocVec()
  172.         function.
  173.         If you set the flag XADCF_FREESKIPINFO with (V3) in xc_Flags, the
  174.         master library parses the xai_SkipInfo list and frees every entry.
  175.  
  176.         If your free function is empty, because all can be done by master
  177.         library, then you may place a zero in xc_Free field of xadClient
  178.         structure and remove the function totally.
  179.  
  180.    INPUTS
  181.         ai      the master communication structure
  182.  
  183.    SEE ALSO
  184.         Example sourcecodes, xadmaster.library/xadFreeInfo()
  185.  
  186. xadClient/xcGetInfo                                       xadClient/xcGetInfo
  187.  
  188.    NAME
  189.         xcGetInfo -- create all information about an archive file
  190.  
  191.    SYNOPSIS
  192.         result = xcGetInfo(ai, xadMasterBase)
  193.           D0               A0        A6
  194.  
  195.         LONG xcGetInfo(struct xadArchiveInfo *, struct xadMasterBase *)
  196.  
  197.    FUNCTION
  198.         This function is the most important one. It creates a structure
  199.         list containing all necessary information. File archivers create
  200.         a linked list of xadFileInfo structures for every file/link/
  201.         directory which is stored in the archive. xadAllocObject helps
  202.         to store that information by providing 3 tags for getting special
  203.         memory. XAD_OBJNAMESIZE can be used to allocate a buffer for
  204.         storing (also multiple) names. The buffer is byte aligned. Do not
  205.         forget to count the 0-byte for every string you want to store there.
  206.         The buffer pointer is stored in xfi_FileName.
  207.         XAD_OBJCOMMENTSIZE is equal to this, but stored in xfi_Comment.
  208.         For file and disk archives there is the flag XAD_OBJPRIVINFOSIZE,
  209.         which returns a longword aligned buffer in xfi_PrivateInfo or
  210.         xdi_PrivateInfo.
  211.         Disk archivers create a linked list of xadDiskInfo structures.
  212.         Normal disk archivers do not allow to store more than one archive,
  213.         so linking is most time not necessary, but it is supported.
  214.         When storing information texts, they must be finished with a zero
  215.         byte, which is not counted in size field!
  216.         Every file or disk entry gets an entrynumber, which increases from
  217.         first to last entry. For mixed archivers this means that a
  218.         "file, disk, disk, file, file, disk" archive gets file entry
  219.         numbers 1,4,5 and disk entry numbers 2,3,6. The number for each
  220.         entry must be exactly the same, if the archive is reopened.
  221.         Most disk archivers are based on cylinder structure. These should
  222.         fill the xadDiskInfo fields correctly. If archivers are not based
  223.         on it (e.g. only sector based) they need to set XADDIF_NOCYLINDER
  224.         flag!
  225.         If the archiver format does not support file dates, set the
  226.         current date (XAD_DATECURRENTTIME tag) and XADFIF_NODATE flag.
  227.         Protection bits default to zero (equals "rwed").
  228.         Archivers may store XADAIF_FILECORRUPT flag in xai_Flags, when 
  229.         archive is corrupt, but some entries are still usable. Unusable
  230.         entries must not appear in entry list. Do not return an error
  231.         code in that case, as an error code always means total failure.
  232.         Starting with V2, an error code may be stored in xai_LastError,
  233.         when XADAIF_FILECORRUPT is used.
  234.  
  235.         Starting with (V3), you may produce a linked list of xadSkipInfo
  236.         structures. The entries must not overlap and there must be at
  237.         least one byte between entries!
  238.         This forces the xadHookTagAccess() function to skip these parts
  239.         for read, copy and input seek operations, when XAD_USESKIPINFO
  240.         tag is used.
  241.  
  242.     The system can handle single crunched files also. These are handled
  243.     as if they where file archives. Set XADFIF_NOFILENAME or
  244.     XADFIF_NOUNCRUNCHSIZE if necessary. In case you set
  245.     XADFIF_NOFILENAME, you should store xadMasterBase->xmb_DefaultName
  246.     as filename. Starting with V7 the master library supplies the
  247.     input name in xai_InName (only if available). This can be used for
  248.     name creation also. You need to allocate name space and copy (and
  249.     modify) that name, as the pointer does not stay valid after leaving
  250.     xcGetInfo().
  251.  
  252.     Filesystem clients need to return XADERR_FILESYSTEM, if the type
  253.     is totally unknown. Else they will break the scanning for other
  254.     filesystems. Do not return any other return codes (except produced
  255.     by low memory or input errors), before you have validated the file
  256.     type. The file list created by filesystems is sorted by name after
  257.     return of xcGetInfo() and the entry numbers are set according to
  258.     new position.
  259.  
  260.    INPUTS
  261.         ai      master communication structure
  262.  
  263.    RESULT
  264.         result  - any of the XADERR codes or zero when all is ok.
  265.  
  266.    SEE ALSO
  267.         Example sourcecodes, xadmaster.library/xadGetInfo()
  268.  
  269. xadClient/xcRecogData                                   xadClient/xcRecogData
  270.  
  271.    NAME
  272.         xcRecogData -- Scan input buffer for known archiver type
  273.  
  274.    SYNOPSIS
  275.         result = xcRecogData(size, buffer, xadMasterBase)
  276.           D0                  D0     A0         A6
  277.  
  278.         BOOL xcRecogData(ULONG, STRPTR, struct xadMasterBase *)
  279.  
  280.    FUNCTION
  281.         Returns non zero when this buffer is part of a archive file
  282.         supported by this client. The recognition should be very stable.
  283.         It should be tested with lots of files. One wrong recognition
  284.         for 100000 files is acceptable.
  285.  
  286.     The minimum size needed for recognition (stored in xadClient
  287.     structure) should not be larger than 1024 bytes if possible.
  288.     Remember, that the master library needs to allocate recognition
  289.     buffers with largest size found in all clients. Scanning archives
  290.     is slowed down, if this size is too large!
  291.  
  292.     This function does not exists for filesystem clients (set its pointer
  293.     to 0).
  294.  
  295.     If you set XADCF_NOCHECKSIZE in client structure, this function is
  296.     also called for buffers shorter than the minimum size specified in
  297.     client structure. This is useful for archiver formats, which have
  298.     different sizes and hard detection schemes (e.g. EXE and SFX types).
  299.     You need to do minimum checks yourself: The minimum passed size may
  300.     be zero (empty file!). Do not read behind buffer borders in any case.
  301.  
  302.    INPUTS
  303.         size    size of passed buffer
  304.         buffer  buffer containing start of file to scan
  305.  
  306.    RESULT
  307.         result - TRUE if archiver is recogniced, FALSE if not
  308.  
  309.    SEE ALSO
  310.         Example sourcecodes, xadmaster.library/xadRecogFile(),
  311.         xadmaster.library/xadGetInfo()
  312.  
  313. xadClient/xcUnArchive                                   xadClient/xcUnArchive
  314.  
  315.    NAME
  316.         xcUnArchive -- write the required entry to destination
  317.  
  318.    SYNOPSIS
  319.         result = xcUnArchive(ai, xadMasterBase)
  320.           D0                 A0        A6
  321.  
  322.         LONG xcUnArchive(struct xadArchiveInfo *, struct xadMasterBase *)
  323.  
  324.    FUNCTION
  325.         This function dearchives one entry. The required entry is passed
  326.         in xai_CurFile or xai_CurDisk. A normal client will support only
  327.         one of the two possibilities, but clients using file and/or disk
  328.         archives are allowed as well. When writing disk data, the client
  329.         should write data in blocks with size of multiple sectorsize.
  330.         Although it should work, it is not recommended to write blocks
  331.         unequal to this.
  332.         Nearly all information you may need is stored in xadArchiveInfo
  333.         structure.
  334.         You may expect the entries to be unarchived in same order as they
  335.         are numbered, but it is not necessary! So be prepared to restart
  336.         decrunching for archivers using blocks or merge methods.
  337.         Disk archivers may expect to be called again to dearchive an
  338.         entry, even if there is only one! So restore the file position
  339.         you need to unarchive.
  340.  
  341.         When XADFIF_SEEKDATAPOS (file archive) or XADDIF_SEEKDATAPOS (disk
  342.         archive) is set, the master automatically seeks to the position in
  343.         xfi_DataPos or xdi_DataPos (V3).
  344.  
  345.         Starting with (V3), a linked list of xadSkipInfo structures
  346.         forces the xadHookTagAccess() function to skip these parts
  347.         for read, copy and input seek operations, when XAD_USESKIPINFO
  348.         tag is used.
  349.  
  350.    INPUTS
  351.         ai      master communication structure
  352.  
  353.    RESULT
  354.         result  - any of the XADERR codes or zero when all is ok.
  355.  
  356.    SEE ALSO
  357.         Example sourcecodes, xadmaster.library/xadDiskunArc(),
  358.         xadmaster.library/xadFileUnArc()
  359.  
  360.